package com.lsh.payment.worker.task;

import com.alibaba.fastjson.JSON;
import com.lsh.payment.core.model.payenum.RefundTaskStatus;
import com.lsh.payment.core.model.payenum.RefundTaskType;
import com.lsh.payment.core.model.refund.RefundTask;
import com.lsh.payment.worker.service.RefundTaskJopService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Project Name: lsh-payment
 *
 * @author peter
 * @date 16/11/9
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
@Component
public class RefundQueryDayJop extends AbstractPayElasticJob {

    private static Logger logger = LoggerFactory.getLogger(RefundQueryDayJop.class);

    @Autowired
    private RefundTaskJopService refundTaskJopService;

    /**
     * 查询任务类型
     *
     * @return 返回类型
     */
    @Override
    protected RefundTaskType getRefundTaskType() {
        return RefundTaskType.REFUND_QUERY;
    }

    /**
     * 执行次数
     *
     * @return 返回结果
     */
    @Override
    protected Integer getDealTimes() {
        return 24;
    }

    /**
     * 获得排除状态
     *
     * @return 返回状态信息
     */
    @Override
    protected RefundTaskStatus getExcludeStatus() {
        return RefundTaskStatus.TASK_SUCCESS;
    }

    /**
     * 处理退款请求
     *
     * @param refundTask 退款任务
     */
    @Override
    protected Boolean processTask(RefundTask refundTask) {
        logger.info("query Jop 处理任务 {}", JSON.toJSONString(refundTask));

        return refundTaskJopService.dealRefundTaskQuery(refundTask);
    }
}
